package com.linuxgt.baidu.zhidao;

/**
 * Created by liuteng on 15-6-16.
 */
public class People {
    private String identity;
    private String name;
    private String sex;

    public static void main(String[] args) throws MyException {
        People people = new People();
        people.sexInputException("aaa");
    }

    public String getIdentity() {
        return identity;
    }

    public void setIdentity(String identity) {
        this.identity = identity;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public boolean sexInputException(String sex) throws MyException {

        String s = "M,F,m,f";//定义可用性别标识
        if (null != sex && "".equals(sex) && sex.length() == 1 && s.contains(sex))
            return true;
        else
            throw new MyException(sex);
    }
}

class MyException extends Exception {
    public MyException(String msg) {
        super(msg + "is illegal value.");
    }
}

